package com.zc.springboot0506.controller.renpf.controller;

import com.zc.springboot0506.controller.renpf.pojo.User;
import com.zc.springboot0506.controller.renpf.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 任鹏飞提交的
 * @create: 2021/6/22
 * @author: Tony Stark
 */
@RequestMapping("rpf")
@RestController
public class RpfController {

    @Autowired
    UsersService usersService;


    @GetMapping("/queryUserList")
    public String queryUserList(){
        List<User> users = usersService.queryUserList();
        for (User user:users){
            System.out.println(user);
        }
        return "ok";
    }
    @GetMapping("/queryById/{id}")
    public String queryById(@PathVariable("id") int id){
       usersService.queryById(id);
        return "ok";
    }
    @GetMapping("/addUser")
    public String addUser(User user){
       usersService.addUser(user);
       return "ok";
    }
    @GetMapping("/updateUser")
    public String updateUser(User user){
     usersService.updateUser(user);
        return "ok";
    }
    @GetMapping("/deleteUser/{id}")
    public String deleteUser(@PathVariable("id")int id){
       usersService.deleteUser(id);
        return "ok";
    }

}
